package cn.zhang.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatHelloWorldController {

    @Resource
    private ChatModel chatModel;

    @GetMapping(value = "/hello/dochat")
    public String doChat(@RequestParam(name = "msg",defaultValue = "你是谁") String msg){
        return chatModel.call(msg);
    }

    @GetMapping(value = "/hello/stringFlux")
    public Flux<String> stringFlux(@RequestParam(name = "msg",defaultValue = "你是谁") String msg){
        return chatModel.stream(msg);
    }


}
